package com.example.fresh_fruit.controller;

import com.example.fresh_fruit.entity.Student;
import com.example.fresh_fruit.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author :飞天の鱼
 * @date : 2022/8/11 17:35
 */
//@Slf4j
@RestController
@RequestMapping("/student")
public class StudentController {

    private static Logger log= LoggerFactory.getLogger("StudentController.class");

    @Autowired
    private StudentService studentService;

    @PostMapping("/insert")
    public boolean insertStudent(Student student) {
        System.out.println("开始增加");
        boolean result = studentService.insertStudent(student);
        //log.info("id:{},name:{}",id,name);
        log.trace("跟踪代码执行流程轨迹的意思");
        log.debug("调试信息");
        log.info("使用的信息");
        log.warn("警告信息");
        log.error("记录异常");
        return result;
    }

    @GetMapping("/querall")
    public List<Student> querall() {
        System.out.println("Controller开始查询所有！");
        return studentService.selectAll();
    }
}
